package com.google.gwt.xml.client.impl;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.xml.client.Node;

/**
 * Dirty, nasty hack so that the XPath implementation can get at some of the 
 * protected methods hidden in the GWT xml library 
 * 
 * @author krogers
 */
public class XPathUtil
{
	/**
	 * Once an XPath has been evaluated, we need to be able to convert the 
	 * resulting javascript objects into nice Java objects - fortunately 
	 * NodeImpl already has a method for doing this, ensuring that the results
	 * will match with the GWT xml api
	 * 
	 * @param object
	 * @return 
	 */
	public static Node build(JavaScriptObject object)
	{
		return NodeImpl.build(object);
	}
	
	/**
	 * In order to perform an XPath query on an element, we will need to be 
	 * able to access the underlying javascript object
	 * 
	 * @param node
	 * @return
	 */
	public static JavaScriptObject getJsObject(Node node)
	{
		NodeImpl impl = (NodeImpl) node;
		return impl.getJsObject();
	}
}